#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[]) {
char string1[] = {"tutorials point"};
char string2[] = {"tutorials point"};
//using function strcmp() to compare the two strings
if (strcmp(string1, string2) == 0)
printf("Yes 2 strings are same\n");
else
printf("No, 2 strings are not same\n" );
return 0;
}
julien@ubuntu:~/0x06$ cat 3-main.c
#include "main.h"
#include <stdio.h>
/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
char s1[] = "Hello";
char s2[] = "World!";
printf("%d\n", _strcmp(s1, s2));
printf("%d\n", _strcmp(s2, s1));
printf("%d\n", _strcmp(s1, s1));
return (0);
}
julien@ubuntu:~/0x06$ gcc -Wall -pedantic -Werror -Wextra -std=gnu89 3-main.c 3-strcmp.c -o 3-strcmp
julien@ubuntu:~/0x06$ ./3-strcmp
-15
15
0
julien@ubuntu:~/0x06$